<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>${message("admin.message.edit")}</title>
<meta name="author" content="EVOLUTION Team" />
<meta name="copyright" content="EVOLUTION" />
<link href="${base}/resources/admin/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${base}/resources/admin/js/jquery.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.tools.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.validate.js"></script>
<script type="text/javascript" src="${base}/resources/admin/editor/kindeditor.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/common.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/input.js"></script>
<style type="text/css">
.roles label {
	width: 150px;
	display: block;
	float: left;
	padding-right: 6px;
}
</style>
<script type="text/javascript">
$().ready(function() {

	var $inputForm = $("#inputForm");
	
	[@flash_message /]
	
    //增加自定义方法:验证输入框是否输入
	$.validator.addMethod("checkInput", 
	  function(value, element, param) {
	    if($(param).length){
	      var paramValue = $(param).val();
	      if ($.trim(paramValue) == ""){
	         return false;
	      } else {
	         return true;
	      }
	    } else {
	       return true;
	    }
	  },
	  "${message("admin.validate.required")}"
	);	
	
	$('#civilDisputeCategoryId').change(function(){
	  $('#civilDisputeNewInputId').remove();
	  $('#tdCivilDisputeCategoryId label[class*="fieldError"]').remove();
	  if($(this).find("option:selected").is(':last-child')){
	     var newInput = '&nbsp;&nbsp;<input name="civilDisputeCategory" id="civilDisputeNewInputId" type="text" placeholder="${message("admin.message.anotherInput")}" class="text fieldError"></input>'+
	                    '<label class="fieldError" for="newInputId">${message("admin.message.inputRequired")}</label>';
	     $('#civilDisputeCategoryId').after(newInput);
	  }
	});
	
	$('#caseCategoryId').change(function(){
	   $('#caseCategoryNewInputId').remove();
	   $('#tdCaseCategoryId label[class*="fieldError"]').remove();
	   if($(this).find("option:selected").is(':last-child')){
	     var newInput = '&nbsp;&nbsp;<input name="caseCategory" id="caseCategoryNewInputId" type="text" placeholder="${message("admin.message.anotherInput")}" class="text fieldError"></input>'+
	                   '<label class="fieldError" for="newInput">${message("admin.message.inputRequired")}</label>';
	     $('#caseCategoryId').after(newInput);
	   }
	});
	
	$('#mainReasonId').change(function(){
	   $('#mainReasonNewInputId').remove();
	   $('#tdMainReasonId label[class*="fieldError"]').remove();
	   if($(this).find("option:selected").is(':last-child')){
	     var newInput = '&nbsp;&nbsp;<input name="mainReason" id="mainReasonNewInputId" type="text" placeholder="${message("admin.message.anotherInput")}" class="text fieldError"></input>'+
	                   '<label class="fieldError" for="newInput">${message("admin.message.inputRequired")}</label>';
	     $('#mainReasonId').after(newInput);	   
	   }
	});
	
	// 表单验证
	$inputForm.validate({
		rules: {
		    gender: "required",
		    idCardNum: {
		      required: true,
		      maxlength: 18
		    },
		    name: "required",
		    mainReason: {
		      required: true,
		      checkInput: "#mainReasonNewInputId"
		    },
		    caseCategory: {
		       required: true,
		       checkInput: "#caseCategoryNewInputId" 
		    },   
		    civilDisputeTimeStamp: "required",
		    civilDisputeResult: "required",
		    civilDisputeCondition: "required",
		    civilDisputeCategory: {
		      required: true,
		      checkInput: "#civilDisputeNewInputId"
		    }
		},
	});
	
});
</script>
</head>
<body>
	<div class="path">
		<a href="${base}/admin/common/index.jhtml">${message("admin.path.index")}</a> &raquo; ${message("admin.message.edit")}
	</div>
	<form id="inputForm" action="save.jhtml" method="post">
	    <input type="hidden" name="penaltyNumber" value="${criminalNumber}" />
		<ul id="tab" class="tab">
			<li>
				<input type="button" value="${message("admin.message.tableOne")}" />
			</li>
		</ul>
		<table class="input tabContent" id="tableOne">
		    <tr>
		       <td colspan="8" class="styleTitle">
		          ${message("admin.message.tableTwoTitle")}
		       </td>
		    </tr>
		    <!-- The first row -->
			<tr>
			    <th>
			        ${message("admin.message.name")}:
			    </th>
			    <td>
			        <input type="text" name="name" value="${name}" class="text" maxlength="20"/>
			    </td>
				<th>
				    ${message("admin.message.gender")}:
				</th>
				<td>
				   <select name="gender">
			       <option value="">${message("admin.common.choose")}</option>
			           [#list genderGroup as masterConfig ]
			             <option value="${masterConfig.cd}" [#if "${gender}" == "${masterConfig.cd}" ]selected="selected"[/#if]>
			                ${masterConfig.decode}
			             </option>
			           [/#list]
			       </select>  				 
				</td>
				<th>
					${message("admin.message.cardId")}:
				</th>
				<td>
					<input name="idCardNum" type="text" class="text" value="${idCardNum}" />
				</td>
			</tr>
			<!-- The second row -->
			<tr>
			    <th rowspan="2">
			        ${message("admin.message.involvedCategory")}:
			    </th>
			    <td colspan="5">
			        ${message("admin.message.intentionalInjuries")}: 
				       <select name="caseCategoryInjure">
				          <option value="">${message("admin.common.choose")}</option>
				          [#list involedCategoryGroup as masterConfig ]
				            [#if "${masterConfig.suppCd}" == "1" ]
				             <option value="${masterConfig.cd}">
				                ${masterConfig.decode}
				             </option>				            
				            [/#if]
				          [/#list]
				       </select>
			    </td>
			</tr>
			<tr>
			   <td colspan="5">
			      ${message("admin.message.intentionalHomicide")}:
			        <select name="caseCatetoryKill">
				          <option value="">${message("admin.common.choose")}</option>
				          [#list involedCategoryGroup as masterConfig ]
				            [#if "${masterConfig.suppCd}" == "2" ]
				             <option value="${masterConfig.cd}">
				                ${masterConfig.decode}
				             </option>				            
				            [/#if]>
				          [/#list]
				    </select>
			   </td>
			</tr>
			
			<!-- The third row -->
			<tr>
			    <th>
			        ${message("admin.message.civilDispute")}:
			    </th>
			    <td id="tdCivilDisputeCategoryId" colspan="5">		       
			       <select id="civilDisputeCategoryId" name="civilDisputeCategory">
				          <option value="">${message("admin.common.choose")}</option>
				          [#list civilDisputeGroup as masterConfig ]
				             <option value="${masterConfig.cd}">
				                ${masterConfig.decode}
				             </option>
				          [/#list]
				    </select>
			    </td>
			</tr>
			
			<!-- The forth row -->
			<tr>
			    <th>
			        ${message("admin.message.civilDisputeCondition")}:
			    </th>
			    <td colspan="5">			        
			        <select name="civilDisputeCondition">
				          <option value="">${message("admin.common.choose")}</option>
				          [#list civilDisputeConditionGroup as masterConfig ]
				             <option value="${masterConfig.cd}">
				                ${masterConfig.decode}
				             </option>
				          [/#list]
				    </select>
			    </td>
			</tr>
			
			
			<!-- The fifth row -->
			<tr>
			    <th>
			        ${message("admin.message.civilDisputeResult")}:
			    </th>
			    <td colspan="5">			      
			        <select name="civilDisputeResult">
				          <option value="">${message("admin.common.choose")}</option>
				          [#list civilDisputeResultGroup as masterConfig ]
				             <option value="${masterConfig.cd}">
				                ${masterConfig.decode}
				             </option>
				          [/#list]
				    </select>
			    </td>
			</tr>		
			
			
			<!-- The sixth row -->
			<tr>
			    <th>
			        ${message("admin.message.civilDisputeTimeStamp")}:
			    </th>
			    <td colspan="5">  		        
			        <select name="civilDisputeTimeStamp">
				          <option value="">${message("admin.common.choose")}</option>
				          [#list civilDisputeTimeStampGroup as masterConfig ]
				             <option value="${masterConfig.cd}">
				                ${masterConfig.decode}
				             </option>
				          [/#list]
				    </select>
			    </td>
			</tr>	
			
			<!-- The seventh row -->
			<tr>
			    <th>
			        ${message("admin.message.caseCategory")}:
			    </th>
			    <td id="tdCaseCategoryId" colspan="5">			    
			        <select id="caseCategoryId" name="caseCategory">
				          <option value="">${message("admin.common.choose")}</option>
				          [#list caseCategoryGroup as masterConfig ]
				             <option value="${masterConfig.cd}">
				                ${masterConfig.decode}
				             </option>
				          [/#list]
				    </select>
			    </td>
			</tr>							
					
			<!-- The ninth row -->
			<tr>
			    <th>
			        ${message("admin.message.mainReason")}:
			    </th>
			    <td id="tdMainReasonId" colspan="5"> 			        
			        <select id="mainReasonId" name="mainReason">
				          <option value="">${message("admin.common.choose")}</option>
				          [#list reasonGroup as masterConfig ]
				             <option value="${masterConfig.cd}">
				                ${masterConfig.decode}
				             </option>
				          [/#list]
				    </select>
			    </td>
			</tr>
		</table>
		<table class="input">
			<tr>
				<td style="text-align:center;">
					<input type="submit" class="button" value="${message("admin.common.submit")}" />
					<input type="button" class="button" value="${message("admin.common.back")}" onclick="location.href='list.jhtml'" />
				</td>
			</tr>
		</table>
	</form>
</body>
</html>